home *** CD-ROM | disk | FTP | other *** search
/ Programming in Microsoft Windows with C# / Programacion en Microsoft Windows con C#.iso / Codigo / Menús / FirstMainMenu / FirstMainMenu.cs next >
Encoding:
Text File  |  2002-06-19  |  3.7 KB  |  102 lines

  1. //--------------------------------------------
  2. // FirstMainMenu.cs ⌐ 2001 by Charles Petzold
  3. //--------------------------------------------
  4. using System;
  5. using System.Drawing;
  6. using System.Windows.Forms;
  7.  
  8. class FirstMainMenu: Form
  9. {
  10.      public static void Main()
  11.      {
  12.           Application.Run(new FirstMainMenu());
  13.      }
  14.      public FirstMainMenu()
  15.      {
  16.           Text = "Primer men· principal";
  17.  
  18.                // Elementos del submen· Archivo
  19.  
  20.           MenuItem miOpen = new MenuItem("&Abrir...",
  21.                                    new EventHandler(MenuFileOpenOnClick),
  22.                                    Shortcut.CtrlA);
  23.  
  24.           MenuItem miSave = new MenuItem("&Guardar",
  25.                                    new EventHandler(MenuFileSaveOnClick),
  26.                                    Shortcut.CtrlG);
  27.  
  28.           MenuItem miSaveAs = new MenuItem("G&uardar como...",
  29.                                    new EventHandler(MenuFileSaveAsOnClick));
  30.  
  31.           MenuItem miDash = new MenuItem("-");
  32.  
  33.           MenuItem miExit = new MenuItem("&Salir",
  34.                                    new EventHandler(MenuFileExitOnClick));
  35.                // Elemento Archivo
  36.  
  37.           MenuItem miFile = new MenuItem("&Archivo",
  38.                                    new MenuItem[] {miOpen, miSave, miSaveAs,
  39.                                                    miDash, miExit });
  40.                // Elementos del submen· Edici≤n
  41.  
  42.           MenuItem miCut = new MenuItem("Cor&tar",
  43.                                    new EventHandler(MenuEditCutOnClick),
  44.                                    Shortcut.CtrlX);
  45.  
  46.           MenuItem miCopy = new MenuItem("&Copiar",
  47.                                    new EventHandler(MenuEditCopyOnClick),
  48.                                    Shortcut.CtrlC);
  49.  
  50.           MenuItem miPaste = new MenuItem("&Pegar",
  51.                                    new EventHandler(MenuEditPasteOnClick),
  52.                                    Shortcut.CtrlV);
  53.                // Elemento Edici≤n
  54.  
  55.           MenuItem miEdit = new MenuItem("&Edici≤n",
  56.                                    new MenuItem[] {miCut, miCopy, miPaste});
  57.  
  58.                // Elemento del submen· Ayuda
  59.  
  60.           MenuItem miAbout = new MenuItem("&Acerca de FirstMainMenu...",
  61.                                    new EventHandler(MenuHelpAboutOnClick));
  62.                // Elemento Ayuda
  63.  
  64.           MenuItem miHelp = new MenuItem("Ay&uda", 
  65.                                    new MenuItem[] {miAbout});
  66.                // Men· principal
  67.  
  68.           Menu = new MainMenu(new MenuItem[] {miFile, miEdit, miHelp});
  69.      }
  70.      void MenuFileOpenOnClick(object obj, EventArgs ea)
  71.      {
  72.           MessageBox.Show("íSeleccionado el elemento Archivo Abrir!", Text);
  73.      }
  74.      void MenuFileSaveOnClick(object obj, EventArgs ea)
  75.      {
  76.           MessageBox.Show("íSeleccionado el elemento Archivo Guardar!", Text);
  77.      }
  78.      void MenuFileSaveAsOnClick(object obj, EventArgs ea)
  79.      {
  80.           MessageBox.Show("íSeleccionado el elemento Archivo Guardar como!", Text);
  81.      }
  82.      void MenuFileExitOnClick(object obj, EventArgs ea)
  83.      {
  84.           Close();
  85.      }
  86.      void MenuEditCutOnClick(object obj, EventArgs ea)
  87.      {
  88.           MessageBox.Show("Seleccionado el elemento Edici≤n Cortar!", Text);
  89.      }
  90.      void MenuEditCopyOnClick(object obj, EventArgs ea)
  91.      {
  92.           MessageBox.Show("Seleccionado el elemento Edici≤n Copiar!", Text);
  93.      }
  94.      void MenuEditPasteOnClick(object obj, EventArgs ea)
  95.      {
  96.           MessageBox.Show("Seleccionado el elemento Edici≤n Pegar!", Text);
  97.      }
  98.      void MenuHelpAboutOnClick(object obj, EventArgs ea)
  99.      {
  100.           MessageBox.Show(Text + " ⌐ 2001 por Charles Petzold");
  101.      }
  102. }